package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo6FlatMap {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setMaster("local")
      .setAppName("map")


    val sc = new SparkContext(conf)

    val rdd1: RDD[String] = sc.parallelize(List("java,spark,java", "hadoop,hive,hbase"))

    /**
      * flatMap: 将一行数据拆分成多行数据
      *
      */

    val rdd2: RDD[String] = rdd1.flatMap((line: String) => line.split(","))


    rdd2.foreach(println)


  }

}
